<?php

namespace App\Http\Servers\User;

use App\Http\Repository\ChunkRepository;
use App\Http\Repository\SetRepository;

class BaseServer
{

    private $setRepository;
    private $chunkRepository;

    public function __construct(SetRepository $setRepository, ChunkRepository $chunkRepository)
    {
        $this->setRepository = $setRepository;
        $this->chunkRepository = $chunkRepository;
    }

    //得到frame
    public function getFrame()
    {
        $tmpName = \Route::current()->getActionName();
        $name = explode("\\", explode("@", $tmpName)[0]);
        $frame['controller'] = config('controller.user')[end($name)]['name'];

        $path = \Route::current()->getName();
        $frame['title'] = config('controller.user')[end($name)]['method'][$path];

        return $frame;
    }

    //得到网站配置信息
    public function getConfig()
    {
        return $this->setRepository->getSet();
    }

    //得到信息模块列表
    public function getChunk()
    {
        return $this->chunkRepository->getChunkUserCanWrite();
    }
}